<!DOCTYPE html>
<html>
<head>
<title>比率设置</title>
<meta charset="utf-8">
<meta name="viewport"
	content="initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no" />

<script type="text/javascript"
	src="//cdn.css.net/libs/jquery/2.2.3/jquery.min.js"></script>
<script type="text/javascript"
	src="//cdn.bootcss.com/noUiSlider/9.2.0/nouislider.js"></script>
<link rel="stylesheet"
	href="//cdn.bootcss.com/noUiSlider/9.2.0/nouislider.css">
<script type="text/javascript" src="${base}/assets/award.js"></script>
<link rel="stylesheet" href="${base}/assets/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="${base}/assets/layui/css/layui.css">
<link rel="stylesheet" href="${base}/assets/style/css/style.css">
<link rel="stylesheet" href="${base}/assets/style/css/lishi.css">
</head>
<body>
	<div class="container-fluid">
		<div class="row daojishi">
			<div class="fl">
				<em id="period">${period!0}</em>期开奖剩余：<span id="time"></span>
			</div>
		</div>
		<div class="row" style="height:40px;"></div>
		<div id="numlist"></div>
		<div class="row" style="height:20px;"></div>
		<div>
			<div class="col-xs-offset-2 col-xs-10" style="text-align: center;">
				<div><label id="sliderValue"></label>%</div>
			</div>
		</div>
		<div>
			<label class="col-xs-2 control-label" style="padding-left:0px;">比&nbsp;&nbsp;率：</label>
			<div class="col-xs-10" style="padding-top:8px;">
				<div class="noUi-control noUi-success" id="slider_0"></div>
			</div>
		</div>
		<nav class="navbar navbar-default navbar-fixed-bottom">
			<div class="btn-group btn-group-justified">
				<div class="btn-group">
					<a class="btn btn-default" href="adm">比率设置</a>
				</div>
				<div class="btn-group">
					<a class="btn btn-default" href="setrate">倍率设置</a>
				</div>
				<div class="btn-group">
					<a class="btn btn-default" href="setagent">代理设置</a>
				</div>
				<div class="btn-group">
					<a class="btn btn-default" href="record">消费记录</a>
				</div>
			</div>
		</nav>
	</div>
	<script type="text/javascript">
		$(document).ready(function() {

			var slider = document.getElementById('slider_0');
			var sliderValue = document.getElementById('sliderValue');

			noUiSlider.create(slider, {
				start : ${key9!0},
				connect : true,
				step : 20,
				range : {
					'min' : 0,
					'max' : 100
				}
			});
			
			slider.noUiSlider.on('update', function( values, handle ){
				var mvalue = Number(values[handle]);
				$.post('savevalue.do', {
					'mkey' : 9,
					'mvalue' : mvalue
				}, function(data) {
					sliderValue.innerHTML = mvalue;
					
					getNumbers();
				});
			});

			showCountDown(${afterTime!0}, ${period!0});

			//每1秒刷新开奖时间数据
			window.setTimeout(loadAwardTimes, 1000);
			
			//每10秒刷新开奖时间数据
			window.setTimeout(getNumbers, 6000);
		});
		
		var getNumbers = function(){
			//更新数据
			$.getJSON('getNumbers.do', {
				termNum : ${period!0},
				t : Math.random()
			}, function(rows) {
				if(rows){
					var maxval = 0;
			    	for(var n in rows){
			    		if(parseInt(rows[n].mvalue)>maxval){
			    			maxval = parseInt(rows[n].mvalue);
			    		}
			    	}
			    	var html = '';
			    	for(var i in rows){
			    		var data = rows[i];
			    		var mvalue = parseInt(data.mvalue);
			    		mvalue = parseInt(mvalue/(maxval==0?1:maxval)*100);
			    		html += '<div class="row col-xs-12" style="padding:0;margin:0;">';
						html += '<div class="nums" style="float:left;margin:4px 0;">';
			    		html += '<i class="ui-logo no'+data.mkey+'">'+data.mkey+'</i>';
			    		html += '</div><div class="progress nums">';
						html += '<div class="progress-bar no'+data.mkey+'" style="width:'+mvalue+'%">';	
						html += '<span class="sr-only">￥'+data.mvalue+'</span>';
						html += '</div></div></div>';
			    	}
			    	$('#numlist').html(html);
			    }
			});
			window.setTimeout(getNumbers, 6000);
		};
	</script>
</body>
</html>
